import Router from 'koa-router'
import { Admin } from '../../service'
const router = new Router();

router.post('/login', async(ctx)=>{
    if(ctx.request.body && ctx.request.body.username && ctx.request.body.password){
        let admin = await Admin.get(ctx.request.body.username)
        if(admin && admin.password == ctx.request.body.password){
            return admin
        }else{
            return null
        }
    }else{
        ctx.throw(401, 'not access');
    }
})

export default router
